<template>
	<view class="results">
		<view class="results_1">
			<view class="img">
				<image src="/static/home/submitSuccess.png"></image>
			</view>
			<view class="sunmit">试卷已提交</view>
		</view>
		<view class="line"></view>
		<view class="fraction">
			<view class="fraction_x">
				<view class="cors">{{score}}</view>
				<view class="fenshu">分数</view>
			</view>
			<view class="fraction_m">
				<view class="one">
					<text class="one_x">题目数量</text>
					<text>{{total_num}}题</text>
				</view>
				<view class="tow">
					<text class="tow_x">错误数</text>
					<text class="tow_m">{{error_num}}</text>
					<text class="tow_b" :style="error_num == 0 ? 'display: none' : ''" @tap="checkWrong">查看错题></text>
				</view>
			</view>
		</view>
		<view class="library">
			<text class="library1">错误题目已自动同步到错题库</text>
			<text class="library2" @tap="wrongQuestion">前往错题库></text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				score: '',
				total_num: '',
				error_num: '',
				exam_id: '',
				course_id: '',
				type: ''
			}
		},
		onLoad(option) {
			this.score = option.score
			this.total_num = option.total_num
			this.error_num = option.error_num
			this.exam_id = option.exam_id
			this.course_id = option.course_id
			this.type = option.type
			console.log(this.type)
			// console.log(this.letterList)
		},
		created() {
			// console.log(this.letterList.length)
		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false;
			}
			if (this.type == 2) {
				this.backPay();
			} else {
				this.back();
			}
			
			return true;
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 2
				});
			},
			backPay() {
				// uni.switchTab({
				// 	url: '/pages/home/home/home'
				// })
				uni.navigateBack({
					delta: 5
				});
			},
			// 查看错题
			checkWrong() {
				uni.navigateTo({
					url: '/pages/home/home/wrongQuestion?exam_id=' + this.exam_id + '&course_id=' + this.course_id
				})
			},
			// 查看错题库
			wrongQuestion() {
				uni.navigateTo({
					url: '/pages/home/home/wrongQuestionBank?course_id=' + this.course_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F5F6F7;
		color: #333333;
		font-size: 32rpx;
	}

	.results_1 {
		background: #FFFFFF;
		padding: 81rpx 0 19rpx 0;

		.img {
			width: 182rpx;
			height: 182rpx;
			margin: 0 auto;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.sunmit {
			text-align: center;
			font-size: 36rpx;
			margin-bottom: 64rpx;
		}
	}

	.line {
		height: 16rpx;
		background: #F5F6F7;
		opacity: 1;
		// margin-top: 64rpx;
	}

	.fraction {
		background: #FFFFFF;
		padding: 35rpx 32rpx 32rpx;

		.fraction_x {
			text-align: center;
			margin-bottom: 67rpx;

			.cors {
				color: #267DFF;
				font-size: 88rpx;
			}

			.fenshu {
				font-size: 28rpx;
			}
		}

		.fraction_m {
			font-size: 28rpx;

			.one {
				margin-bottom: 32rpx;

				.one_x {
					color: #999999;
					margin-right: 56rpx;
				}
			}

			.tow {
				.tow_x {
					color: #999999;
					margin-right: 56rpx;
				}

				.tow_m {
					color: #FF4040;
					margin-right: 66rpx;
				}

				.tow_b {
					color: #267DFF;
				}
			}
		}
	}

	.library {
		padding: 40rpx 32rpx 0;
		font-size: 28rpx;

		.library1 {
			color: #999999;
			margin-right: 24rpx;
		}

		.library2 {
			color: #267DFF;
		}
	}
</style>
